package com.example.blew.omp.system.model.converter;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.example.blew.omp.system.model.form.UserForm;
import com.example.blew.omp.system.model.po.User;

import java.util.ArrayList;
import java.util.List;

public class UserConverter {

    public static User converterToPoByFrom(UserForm source){
        if (source == null) {
            return null;
        }
        User target = new User();
        BeanUtil.copyProperties(source, target);
        return target;
    }

    public static List<User> converterToPoByFrom(List<UserForm> sources){
        if (CollUtil.isEmpty(sources)) {
            return null;
        }
        List<User> result=new ArrayList<>();
        for(UserForm source: sources){
            User target = new User();
            BeanUtil.copyProperties(source, target);
            result.add(target);
        }
        return result;

    }
}
